<template>
  <div class="index-page-header">
    <div class="header-left"></div>
    <div class="header-center">
      和林格尔县现代农牧业产业园数据平台
    </div>
    <div class="header-tools">
      <div class="tools-item">{{nowTime.year}}</div>
      <div class="tools-item">{{nowTime.week}}</div>
      <div class="tools-item">{{nowTime.time}}</div>
      <screenfull :element="element" class="screen"></screenfull>
<!--      <div @click="handleFullScreen"></div>-->
<!--      <svg-icon class="tools-item" :icon-class="isFullscreen?'exit-fullscreen':'fullscreen'" @click="click" />-->
      <div class="tools-back">退出</div>
    </div>
  </div>
</template>

<script>
import dayjs from 'dayjs'
import Screenfull from '@/components/Screenfull'


export default {
  components:{
    Screenfull
  },
  data(){
    return{
      isFullscreen:false,
      timer:null,
      nowTime:'',
      element:''
    }
  },
  created() {
    this.getTime()
    this.timer = setInterval(()=>{
      this.getTime()
    },1000)
  },
  mounted() {
    this.element = document.querySelector('.app-main')
  },
  beforeDestroy() {
    clearInterval(this.timer)
    this.timer = null
  },
  methods:{
    getTime(){
      const weekMap = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
      let dayData = dayjs()
      let year = dayData.format('YYYY/MM/DD')
      let time = dayData.format('HH:mm:ss')
      let week = dayData.format('d')
      this.nowTime = {
        year,
        time,
        week: weekMap[week]
      }
    },
  }
}
</script>

<style scoped lang="scss">
.index-page-header{
  width: 100%;
  height: 100%;
  background-image: url("../../assets/images/head.png");
  background-size: 100% 100%;
  display: flex;
  padding-right: 0.1rem;
  .header-left ,.header-center, .header-tools{
    flex: 1;
  }
  .header-center{
    font-family: Source Han Sans CN;
    font-weight: 500;
    font-size: 13px;
    display: flex;
    justify-content: center;
    align-items: center;
    letter-spacing: 0.01rem;
    padding-left: 0.1rem;
  }
  .header-tools{
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-top: 0.1rem;
    vertical-align: top;
    line-height: 0.3rem;
    font-size: 0.2rem;

    .screen{
      margin-left: 0.2rem;
    }
    .tools-item{
      margin-left:0.21rem;
    }
    .tools-back{
      margin-left: 0.21rem;
    }
  }
}

</style>
